<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>

function check (str) {
    var strArr = str.split('')
    var queue = []
    var obj = {
        '}': '{',
        ']': '[',
        ')': '('
    }

    console.log('strArr:', strArr)
    for (var i = 0, length = strArr.length; i < length; i++) {
        if (strArr[i] === '{' || strArr[i] === '[' || strArr[i] === '(') {
            queue.push(strArr[i])
        } else {
            console.log('queue:', queue)
            if (queue[queue.length - 1] !== obj[strArr[i]]) {
                console.log('queue[queue.length - 1]:', queue[queue.length - 1])
                console.log('strArr[i]:', obj[strArr[i]])
                return false
            }
            queue.pop()
        }
    }
    console.log('queue:', queue)
    return queue.length === 0
}


var str

str = '{[(])}'
// str = '{[()]'

console.log(check(str))

</script>
</body>
</html>